package by.bsuir.chess.models
{
	import by.bsuir.chess.enums.Color;
	import by.bsuir.chess.vo.Piece;

	import flash.geom.Point;

	public class BoardState
	{
		private static var _main_state : Array;

		init();
		initMainState();

		private static function init() : void
		{
			for (var i : int = 0; i <= 8; i ++)
				for (var j : int = 0; j <= 8; j ++)
				{
					_main_state[i][j] = null;
				}
		}

		private static function initMainState() : void
		{
			_main_state = [
				[]
			];

			_main_state[1][1] = new Piece(Piece.ROOK, new Point(1, 1), Color.WHITE);
			_main_state[2][1] = new Piece(Piece.KNIGHT, new Point(2, 1), Color.WHITE);
			_main_state[3][1] = new Piece(Piece.BISHOP, new Point(3, 1), Color.WHITE);
			_main_state[4][1] = new Piece(Piece.QUEEN, new Point(4, 1), Color.WHITE);
			_main_state[5][1] = new Piece(Piece.KING, new Point(5, 1), Color.WHITE);
			_main_state[6][1] = new Piece(Piece.BISHOP, new Point(6, 1), Color.WHITE);
			_main_state[7][1] = new Piece(Piece.KNIGHT, new Point(7, 1), Color.WHITE);
			_main_state[8][1] = new Piece(Piece.ROOK, new Point(8, 1), Color.WHITE);

			_main_state[1][2] = new Piece(Piece.PAWN, new Point(1, 2), Color.WHITE);
			_main_state[2][2] = new Piece(Piece.PAWN, new Point(2, 2), Color.WHITE);
			_main_state[3][2] = new Piece(Piece.PAWN, new Point(3, 2), Color.WHITE);
			_main_state[4][2] = new Piece(Piece.PAWN, new Point(4, 2), Color.WHITE);
			_main_state[5][2] = new Piece(Piece.PAWN, new Point(5, 2), Color.WHITE);
			_main_state[6][2] = new Piece(Piece.PAWN, new Point(6, 2), Color.WHITE);
			_main_state[7][2] = new Piece(Piece.PAWN, new Point(7, 2), Color.WHITE);
			_main_state[8][2] = new Piece(Piece.PAWN, new Point(8, 2), Color.WHITE);

			_main_state[1][8] = new Piece(Piece.ROOK, new Point(1, 8), Color.BLACK);
			_main_state[2][8] = new Piece(Piece.KNIGHT, new Point(2, 8), Color.BLACK);
			_main_state[3][8] = new Piece(Piece.BISHOP, new Point(3, 8), Color.BLACK);
			_main_state[4][8] = new Piece(Piece.QUEEN, new Point(4, 8), Color.BLACK);
			_main_state[5][8] = new Piece(Piece.KING, new Point(5, 8), Color.BLACK);
			_main_state[6][8] = new Piece(Piece.BISHOP, new Point(6, 8), Color.BLACK);
			_main_state[7][8] = new Piece(Piece.KNIGHT, new Point(7, 8), Color.BLACK);
			_main_state[8][8] = new Piece(Piece.ROOK, new Point(8, 8), Color.BLACK);

			_main_state[1][7] = new Piece(Piece.PAWN, new Point(1, 7), Color.BLACK);
			_main_state[2][7] = new Piece(Piece.PAWN, new Point(2, 7), Color.BLACK);
			_main_state[3][7] = new Piece(Piece.PAWN, new Point(3, 7), Color.BLACK);
			_main_state[4][7] = new Piece(Piece.PAWN, new Point(4, 7), Color.BLACK);
			_main_state[5][7] = new Piece(Piece.PAWN, new Point(5, 7), Color.BLACK);
			_main_state[6][7] = new Piece(Piece.PAWN, new Point(6, 7), Color.BLACK);
			_main_state[7][7] = new Piece(Piece.PAWN, new Point(7, 7), Color.BLACK);
			_main_state[8][7] = new Piece(Piece.PAWN, new Point(8, 7), Color.BLACK);
		}

		public static function get MAIN_STATE() : Array
		{
			return _main_state;
		}
	}
}
